import ourcity.news.models as nm

from django.contrib.sites.models import Site

def location(request):
    location = {}

    current_site = Site.objects.get_current()
    location['site'] = current_site

    script_name = request.META['SCRIPT_NAME']
    location['script_name'] = script_name

    path = request.META['PATH_INFO']
    location['path'] = path

    url = 'http://%s%s%s' % (current_site, script_name, path)
    location['url'] = url

    return {'location': location}

def recent(request):
    extra_context = {}
    extra_context['recent_reports'] = nm.News.objects.reports()[:5]
    extra_context['recent_news'] = nm.News.objects.posts()[:5]
    return extra_context

